package com.xsmart.goods.api;

import com.xsmart.common.entity.RequestBean;
import com.xsmart.goods.services.GoodsManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;


/**
 * @author xuqinyuan
 */
@Controller
@RequestMapping("/api")
public class GoodsManageController {

    @Autowired
    GoodsManageService goodsManageService;

    @RequestMapping(value = "/v1/GoodsManageService/queryGoods", method= RequestMethod.POST)
    @ResponseBody
    public Object queryGoods(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        return goodsManageService.queryGoods(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsManageService/queryShopList")
    @ResponseBody
    public Object queryShopList(@ModelAttribute RequestBean requestBean, HttpServletRequest request){
        return goodsManageService.queryShopList(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsManageService/addGoods", method= RequestMethod.POST)
    @ResponseBody
    public Object addGoods(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        return goodsManageService.addGoods(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsManageService/modGoods", method= RequestMethod.POST)
    @ResponseBody
    public Object modGoods(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        return goodsManageService.modGoods(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsManageService/delGoods", method= RequestMethod.POST)
    @ResponseBody
    public Object delGoods(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        return goodsManageService.delGoods(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsManageService/checkGoodsSn", method= RequestMethod.POST)
    @ResponseBody
    public Object checkGoodsSn(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        return goodsManageService.checkGoodsSn(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsManageService/querySellerShop", method= RequestMethod.POST)
    @ResponseBody
    public Object querySellerShop(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        return goodsManageService.querySellerShop(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsManageService/queryGoodsPhoto", method= RequestMethod.POST)
    @ResponseBody
    public Object queryGoodsPhoto(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        return goodsManageService.queryGoodsPhoto(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsManageService/queryGoodsSingle", method= RequestMethod.POST)
    @ResponseBody
    public Object queryGoodsSingle(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        System.out.println("----------");
        return goodsManageService.queryGoodsSingle(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsManageService/queryGoodComments", method= RequestMethod.POST)
    @ResponseBody
    public Object queryGoodComments(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {

        return goodsManageService.queryGoodComments(requestBean);
    }


    @RequestMapping(value = "/v1/GoodsManageService/queryMidComments", method= RequestMethod.POST)
    @ResponseBody
    public Object queryMidComments(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        System.out.println("----------");
        return goodsManageService.queryMidComments(requestBean);
    }

    @RequestMapping(value = "/v1/GoodsManageService/queryNativeComments", method= RequestMethod.POST)
    @ResponseBody
    public Object queryNativeComments(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        System.out.println("++++++++");
        return goodsManageService.queryNativeComments(requestBean);
    }

    /**
    * 商品列表步骤一保存
    *@author xxf
    * @date 2018/2/22
    */
    @RequestMapping(value = "/v1/GoodsManageService/modGoodsCat", method= RequestMethod.POST)
    @ResponseBody
    public Object modGoodsCat(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        return goodsManageService.modGoodsCat(requestBean);
    }

    /**
     * 商品列表步骤二保存
     *@author xxf
     * @date 2018/2/22
     */
    @RequestMapping(value = "/v1/GoodsManageService/modGoodsGI", method= RequestMethod.POST)
    @ResponseBody
    public Object modGoodsGI(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        return goodsManageService.modGoodsGI(requestBean);
    }

    /**
     * 商品列表步骤三保存
     *@author xxf
     * @date 2018/2/22
     */
    @RequestMapping(value = "/v1/GoodsManageService/modGoodsSI", method= RequestMethod.POST)
    @ResponseBody
    public Object modGoodsSI(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        System.out.println("+++++");
        return goodsManageService.modGoodsSI(requestBean);
    }

    /**
     * 商品列表第四步单独存储
     * @author xxf
     * @date 2018/2/22
     * */
    @RequestMapping(value = "/v1/GoodsManageService/modGoodsAttr", method= RequestMethod.POST)
    @ResponseBody
    public Object modGoodsAttr(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        return goodsManageService.modGoodsAttr(requestBean);
    }

    /**
     * 更改商品的状态
     * @param requestBean
     * @param httpServletRequest
     * @return
     */
    @RequestMapping(value = "/v1/GoodsManageService/changeOnsale", method= RequestMethod.POST)
    @ResponseBody
    public Object changeOnsale(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest) {
        return goodsManageService.changeOnsale(requestBean);
    }

}
